<?php

use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;

class User extends Eloquent implements UserInterface, RemindableInterface {

	use UserTrait, RemindableTrait;

	public function role()
    {
		return $this->belongsTo('Role');
	}

	public function unit()
    {
		return $this->belongsTo('Unit');
	}

    public function createLessons()
    {
        return $this->hasMany('Lesson', 'teacher_id', 'id');
    }

    public function joinLessons()
    {
        return $this->belongsToMany('Lesson', 'lesson_students', 'student_id', 'lesson_id');
    }

	/**
	 * The database table used by the model.
	 *
	 * @var string
	 */
	protected $table = 'users';

	/**
	 * The attributes excluded from the model's JSON form.
	 *
	 * @var array
	 */
	protected $guarded = array('id');

    protected $hidden = ['password', 'created_at', 'updated_at'];

}
